package(
    default_visibility = ["//visibility:public"],
    licenses = ["notice"],
)

cc_library(
    name = "common",
    hdrs = ["common.h"],
    tags = ["local"],
    deps = [
        "//scann/data_format:datapoint",
        "//scann/oss_wrappers:scann_bits",
        "//scann/utils:types",
    ],
)

cc_library(
    name = "binary_distance_measure_base",
    srcs = ["binary_distance_measure_base.cc"],
    hdrs = ["binary_distance_measure_base.h"],
    tags = ["local"],
    deps = [
        ":common",
        "//scann/distance_measures:distance_measure_base",
        "@com_google_absl//absl/numeric:bits",
    ],
)

cc_library(
    name = "cosine_distance",
    srcs = ["cosine_distance.cc"],
    hdrs = ["cosine_distance.h"],
    tags = ["local"],
    deps = [
        ":binary_distance_measure_base",
        ":common",
        ":dot_product",
        "//scann/distance_measures:distance_measure_base",
        "//scann/oss_wrappers:scann_bits",
        "//scann/utils:types",
        "@com_google_absl//absl/numeric:bits",
    ],
    alwayslink = 1,
)

cc_library(
    name = "dot_product",
    srcs = ["dot_product.cc"],
    hdrs = ["dot_product.h"],
    tags = ["local"],
    deps = [
        ":binary_distance_measure_base",
        ":common",
        ":dot_product_avx1",
        ":dot_product_avx2",
        ":dot_product_sse4",
        "//scann/distance_measures:distance_measure_base",
        "//scann/utils:reduction",
        "//scann/utils:types",
        "//scann/utils/intrinsics:flags",
    ],
    alwayslink = 1,
)

cc_library(
    name = "dot_product_impl",
    tags = ["local"],
    textual_hdrs = ["dot_product_impl.inc"],
    deps = ["//scann/data_format:datapoint"],
    alwayslink = 1,
)

cc_library(
    name = "dot_product_avx1",
    srcs = ["dot_product_avx1.cc"],
    hdrs = ["dot_product_avx1.h"],
    tags = ["local"],
    deps = [
        ":dot_product_impl",
        "//scann/data_format:datapoint",
        "//scann/utils/internal:avx_funcs",
        "//scann/utils/intrinsics:attributes",
        "//scann/utils/intrinsics:avx1",
    ],
    alwayslink = 1,
)

cc_library(
    name = "dot_product_avx2",
    srcs = ["dot_product_avx2.cc"],
    hdrs = ["dot_product_avx2.h"],
    tags = ["local"],
    deps = [
        ":dot_product_impl",
        "//scann/data_format:datapoint",
        "//scann/utils/internal:avx2_funcs",
        "//scann/utils/intrinsics:attributes",
        "//scann/utils/intrinsics:avx2",
    ],
    alwayslink = 1,
)

cc_library(
    name = "dot_product_sse4",
    srcs = ["dot_product_sse4.cc"],
    hdrs = ["dot_product_sse4.h"],
    tags = ["local"],
    deps = [
        "//scann/data_format:datapoint",
        "//scann/utils/intrinsics:attributes",
        "//scann/utils/intrinsics:sse4",
    ],
    alwayslink = 1,
)

cc_library(
    name = "hamming_distance",
    srcs = ["hamming_distance.cc"],
    hdrs = ["hamming_distance.h"],
    tags = ["local"],
    deps = [
        ":binary_distance_measure_base",
        ":common",
        "//scann/distance_measures:distance_measure_base",
        "//scann/utils:reduction",
        "//scann/utils:types",
    ],
    alwayslink = 1,
)

cc_library(
    name = "jaccard_distance",
    srcs = ["jaccard_distance.cc"],
    hdrs = ["jaccard_distance.h"],
    tags = ["local"],
    deps = [
        ":binary_distance_measure_base",
        ":common",
        "//scann/distance_measures:distance_measure_base",
        "//scann/utils:reduction",
        "//scann/utils:types",
        "@com_google_absl//absl/numeric:bits",
    ],
    alwayslink = 1,
)

cc_library(
    name = "l1_distance",
    srcs = ["l1_distance.cc"],
    hdrs = ["l1_distance.h"],
    tags = ["local"],
    deps = [
        ":common",
        ":l1_distance_sse4",
        "//scann/distance_measures:distance_measure_base",
        "//scann/utils:reduction",
        "//scann/utils:types",
        "//scann/utils/intrinsics:flags",
    ],
    alwayslink = 1,
)

cc_library(
    name = "l1_distance_sse4",
    srcs = ["l1_distance_sse4.cc"],
    hdrs = ["l1_distance_sse4.h"],
    tags = ["local"],
    deps = [
        "//scann/data_format:datapoint",
        "//scann/utils/intrinsics:attributes",
        "//scann/utils/intrinsics:sse4",
    ],
    alwayslink = 1,
)

cc_library(
    name = "l2_distance",
    srcs = ["l2_distance.cc"],
    hdrs = ["l2_distance.h"],
    tags = ["local"],
    deps = [
        ":common",
        ":l2_distance_avx1",
        ":l2_distance_sse4",
        "//scann/distance_measures:distance_measure_base",
        "//scann/utils:reduction",
        "//scann/utils:types",
        "//scann/utils/intrinsics:flags",
    ],
    alwayslink = 1,
)

cc_library(
    name = "l2_distance_avx1",
    srcs = ["l2_distance_avx1.cc"],
    hdrs = ["l2_distance_avx1.h"],
    tags = ["local"],
    deps = [
        "//scann/data_format:datapoint",
        "//scann/utils/intrinsics:attributes",
        "//scann/utils/intrinsics:avx1",
    ],
    alwayslink = 1,
)

cc_library(
    name = "l2_distance_sse4",
    srcs = ["l2_distance_sse4.cc"],
    hdrs = ["l2_distance_sse4.h"],
    tags = ["local"],
    deps = [
        "//scann/data_format:datapoint",
        "//scann/utils/intrinsics:attributes",
        "//scann/utils/intrinsics:sse4",
    ],
    alwayslink = 1,
)

cc_library(
    name = "limited_inner_product",
    srcs = ["limited_inner_product.cc"],
    hdrs = ["limited_inner_product.h"],
    copts = ["-fno-tree-vectorize"],
    tags = ["local"],
    deps = [
        ":common",
        ":dot_product",
        ":l2_distance",
        "//scann/distance_measures:distance_measure_base",
        "//scann/utils:types",
    ],
    alwayslink = 1,
)

cc_library(
    name = "nonzero_intersect_distance",
    srcs = ["nonzero_intersect_distance.cc"],
    hdrs = ["nonzero_intersect_distance.h"],
    tags = ["local"],
    deps = [
        ":common",
        ":dot_product",
        "//scann/data_format:datapoint",
        "//scann/distance_measures:distance_measure_base",
        "//scann/oss_wrappers:scann_aligned_malloc",
        "//scann/oss_wrappers:scann_down_cast",
        "//scann/oss_wrappers:tf_dependency",
        "//scann/utils:reduction",
        "@com_google_absl//absl/base",
        "@com_google_absl//absl/flags:flag",
        "@com_google_absl//absl/log",
    ],
    alwayslink = 1,
)
